<?php $this->load->view('layout/header_data_form');?>
<?php $this->load->view('layout/logo');?>
<div id="wrap">
  
    <table border="0" cellpadding="5" cellspacing="0">
      <tr>
        <td width="400" valign="top">
        <form id="form1" name="form1" method="post" action="">
        <table border="0" cellpadding="7" cellspacing="0">
          <tr>
            <td align="right"><strong>Investment:</strong></td>
            <td><table border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td><select name="investment_type1" class="field" id="select2">
                      <option <?php echo(isset($row['left']) && $row['left']['investment_type'] == 'Lump Sum' ? 'selected="selected"' : '');?> value="Lump Sum">Lump Sum</option>
                        <option <?php echo(isset($row['left']) && $row['left']['investment_type'] == 'Yearly' ? 'selected="selected"' : '');?> value="Yearly">Yearly</option>
                    </select>                  </td>
                  <td><input name="amount1" value="<?php echo(isset($row['left']) ? $row['left']['amount'] : '');?>" type="text" class="field" id="textfield3" size="30" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td align="right"><strong>Duration:</strong></td>
            <td><input value="<?php echo(isset($row['left']) ? $row['left']['duration'] : '');?>" name="duration1" type="text" class="field" id="textfield4" size="20" /></td>
          </tr>
          <tr>
            <td align="right"><strong>% of Returns:</strong></td>
            <td><input value="<?php echo(isset($row['left']) ? $row['left']['percent_return'] : '');?>" name="percent_return1" type="text" class="field" id="textfield7" size="20" /></td>
          </tr>
          <!--<tr>
            <td align="right"><strong>Inflation:</strong></td>
            <td><input name="textfield3" type="text" class="field" id="textfield8" size="40" /></td>
          </tr>-->
          <tr>
            <td align="right">&nbsp;</td>
            <td>
            	<input type="submit" class="large button green" value="Calculate"/>
            	<input type="hidden" name="submit" value="0"/>
              	<input type="hidden" name="type" value="1"/>
            </td>
          </tr>
          <tr>
            <td align="right">&nbsp;</td>
            <td>
              <?php if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["type"]) && $_POST["type"] == 1):?>
              <div id="one" style="">
		        <table border="0" cellpadding="5" cellspacing="0">
		          <tr>
		            <td align="left" valign="top"><strong>Saving:</strong></td>
		            <td align="left" valign="top">
		            	<?php
		            	$FV =0;
	            		//echo $row['left']['investment_type'];
	            		$r	=	$row["left"]["percent_return"]/100;
	            		if(isset($row['left']) && $row['left']['investment_type'] == 'Lump Sum'){
	            			$FV	=	$row["left"]["amount"]*(pow((1+$r),$row["left"]["duration"]));
	            			//echo "sdsd";
	            		}
	            		else 
	            		{
	            			
	            			$FV	=	$row["left"]["amount"]*(pow((1+$r),($row["left"]["duration"]-1)))/$r;
	            		}
		            	?>
		            	<span class="red-text">S$<?php echo number_format($FV,2);?></span>
		            </td>
		          </tr>
		        </table>
		      </div>
		      <?php endif;?>            
        	</td>
          </tr>
          
        </table>
        </form>
        </td>
        <form method="post" action="">
        <td valign="top"><table border="0" cellpadding="7" cellspacing="0">
            <tr>
              <td align="right"><strong>Investment:</strong></td>
              <td>
              <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><select name="investment_type2" class="field" id="select2">
                        <option <?php echo(isset($row['right']) && $row['right']['investment_type'] == 'Lump Sum' ? 'selected="selected"' : '');?> value="Lump Sum">Lump Sum</option>
                        <option <?php echo(isset($row['right']) && $row['right']['investment_type'] == 'Yearly' ? 'selected="selected"' : '');?> value="Yearly">Yearly</option>
                      </select>                    </td>
                    <td><input value="<?php echo(isset($row['right']) ? $row['right']['amount'] : '');?>" name="amount2" type="text" class="field" id="textfield3" size="30" /></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td align="right"><strong>Duration:</strong></td>
              <td><input value="<?php echo(isset($row['right']) ? $row['right']['duration'] : '');?>" name="duration2" type="text" class="field" id="textfield4" size="20" /></td>
            </tr>
            <tr>
              <td align="right"><strong>% of Returns:</strong></td>
              <td><input value="<?php echo(isset($row['right']) ? $row['right']['percent_return'] : '');?>" name="percent_return2" type="text" class="field" id="textfield7" size="20" /></td>
            </tr>
            <!--<tr>
              <td align="right"><strong>Inflation:</strong></td>
              <td><input name="textfield3" type="text" class="field" id="textfield8" size="40" /></td>
            </tr>-->
            <tr>
              <td align="right">&nbsp;</td>
              <td>
              	<input type="submit" class="large button green" value="Calculate"/>
              	<input type="hidden" name="submit" value="0"/>
              	<input type="hidden" name="type" value="2"/>
              </td>
            </tr>
            <tr>
              <td align="right">&nbsp;</td>
              <td>
              <?php if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["type"]) && $_POST["type"] == 2):?>
               <div id="two" style="">
		        <table border="0" cellpadding="5" cellspacing="0">
		          <tr>
		            <td align="left" valign="top"><strong>Saving:</strong></td>
		            <td align="left" valign="top">
		            <?php
		            	$FV =0;
	            		//echo $row['left']['investment_type'];
	            		$r	=	$row["right"]["percent_return"]/100;
	            		if(isset($row['right']) && $row['right']['investment_type'] == 'Lump Sum'){
	            			$FV	=	$row["right"]["amount"]*(pow((1+$r),$row["right"]["duration"]));
	            			//echo "sdsd";
	            		}
	            		else 
	            		{
	            			
	            			$FV	=	$row["right"]["amount"]*(pow((1+$r),($row["right"]["duration"]-1)))/$r;
	            		}
		            	?>
		            	<span class="red-text">S$<?php echo number_format($FV,2);?></span>
		            </td>
		          </tr>
		        </table>
		        </div> 
		      <?php endif;?>               
        		</td>
            </tr>
        </table></td>
        </form>
      </tr>
      <form method="post" action="">
      <tr>
        <td>
        
        <div id="graph" style="display:none">
        <img src="images/graph.jpg" alt="Graph" width="400" height="285" />
            <table border="0" cellpadding="7" cellspacing="0">
              <tr>
                <td align="left"><strong>Explanation:</strong></td>
              </tr>
              <tr>
                <td align="left"><textarea name="textfield3" cols="60" rows="6" class="field" id="textfield3"></textarea></td>
              </tr>
              <tr>
                <td align="right"><input name="input" type="image" src="<?php echo img_link('submit.gif');?>" onclick="JavaScript:window.close()" /></td>
              </tr>
          </table>
          </div>        </td>
        <td>
        
         <div id="graph2" style="display:none">
        <img src="images/graph.jpg" alt="Graph" width="400" height="285" />
            <table border="0" cellpadding="7" cellspacing="0">
              <tr>
                <td align="left"><strong>Explanation:</strong></td>
              </tr>
              <tr>
                <td align="left"><textarea name="textfield3" cols="60" rows="6" class="field" id="textfield3"></textarea></td>
              </tr>
              <tr>
                <td align="right"><input name="input" type="image" src="<?php echo img_link('submit.gif');?>" onclick="JavaScript:window.close()" /></td>
              </tr>
          </table>
          </div>        </td>
      </tr>
      <tr>
        <td colspan="2" align="right">
        	<input class="large button red" type="submit" value="Submit"/>
        	<input type="hidden" name="submit" value="1"/>
        </td>
      </tr>
      </form>
    </table>
    
    <?php $this->load->view('layout/close_form');?>
</div>
<?php $this->load->view('layout/footer_data_form');?>  
  
</div>